<template>
	<view class="floor-box">
		<view class="search">
			<view class="search-radius">
				<u-icon name="search" color="#D1D1D1" size="28"></u-icon>
				<u-input placeholder="输入楼栋编号" type="text" v-model="keywords"/>
				<button type="default" size="mini" @click="getQueryFloors(communityId,keywords)">搜索</button>
			</view>
		</view>

		<view class="content-box">
			<cell :bg_url="0" v-for="item in floorInfo.list" :key="item.floorId" @click.native="_navBack(item)">
				<!-- <text class="iconfont custom-icon--yonghu" slot="icon">{{99}}</text> -->
				<text slot="name">{{item.floorName}}</text>
			</cell>
		</view>
	</view>
</template>

<script>
	import Cell from '@/components/location/location.vue' //位置内容
	import {
		getQueryFloors
	} from "@/api/common.js"
	export default {
		components: {
			Cell,
		},
		data() {
			return {
				floorInfo: {
					list: [],
				},
				keywords:"",
				communityId:""
			}
		},
		onLoad(option) {
			this.communityId = option.communityId
			this.getQueryFloors(this.communityId,this.keywords)
		},
		methods: {
			/**
			 * 返回上一级
			 */
			_navBack(row) {
				let object = {
					floorId: row.floorId,
					floorName: row.floorName,
				}
				let pages = getCurrentPages(); //获取所有页面
				let prevPage = pages[pages.length - 2] //获取上级页面
				prevPage.$vm.floorFun(object);
				uni.navigateBack();
			},
			/**
			 * 获取楼栋
			 */
			getQueryFloors(communityId,keywords) {
				const data = {
					page: '1',
					row: '10',
					communityId,
					floorName: keywords,
				}
				getQueryFloors(data).then(res => {
					this.floorInfo.list = res.apiFloorDataVoList
				})
			},

		}
	}
</script>

<style lang="scss">
	.floor-box{
		background-color: #FFFFFF;
		.search {
			width: 100%;
			padding: 24rpx;
		
			.search-radius {
				display: flex;
				justify-content: space-between;
				border-radius: 8rpx;
				background: #F3F3F3;
				overflow: hidden;
		
				u-icon {
					width: 66rpx;
		
					view {
						margin: 0 auto;
					}
				}
		
				u-input {
					flex: 1;
				}
		
				button {
					// width: 130rpx;
					margin: 0;
					background: #1585FC;
					color: #FFFFFF;
					font-family: SourceHanSansCN-Medium, SourceHanSansCN;
					font-weight: 500;
					border-radius: 0;
					line-height: 64rpx !important;
				}
		
				button:after {
					border-radius: 0;
				}
			}
		
		}
		
		.content-box {
			padding: 0 36rpx;
			width: 100%;
		}
	}
	
</style>
